home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1997 January: Mac OS SDK / Dev.CD Jan 97 SDK2.toast / Development Kits (Disc 2) / OpenDoc / OpenDoc Development / Debugging Support / OpenDoc™ Source Code / Storage / DragPriv.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1996-08-28  |  19.5 KB  |  664 lines  |  [TEXT/MPS ]

  1. /*
  2.     File:        DragPriv.cpp
  3.  
  4.     Contains:    Implementation of Private classes for ODDragAndDrop.
  5.  
  6.     Owned by:    Vincent Lo
  7.  
  8.     Copyright:    © 1994 - 1996 by Apple Computer, Inc., all rights reserved.
  9.  
  10.     Change History (most recent first):
  11.  
  12.         <10>     7/18/96    DH        #136990:Drags don't contain all types. Now
  13.                                     correctly counts drag item flavors.
  14.          <9>     7/11/96    DH        1365986    1.1GM: Crash when drag fails and
  15.                                     another drag is attempted. Fixed many stale
  16.                                     object references.
  17.          <8>     6/21/96    DH        1353507: 1.0.x: Dragging Scrapbook OpenDoc
  18.                                     clipping to document can cause crash.
  19.          <6>     5/23/96    DH        1344338: Force quit of document when
  20.                                     dragging 'Bad' file or Container. Turned
  21.                                     off fatal Bento errors for Open and Create
  22.                                     container operations.
  23.          <5>     5/15/96    DH        Removed bogus include so that will build
  24.                                     will not be broken!
  25.          <4>     5/13/96    DH        1305572 - 1.1MRD:[Cyberdog]Dragging
  26.                                     multiple items *really* slow.
  27.                                     1314704 - 1.0.x: Enourmous performance hit
  28.                                     when dragging numb erous items over
  29.                                     windows.
  30.          <3>      5/1/96    JA        1314704: Allow ODMemDragItem to use
  31.                                     pre-existing container.
  32.          <2>     3/15/96    DH        1287259 - 1.0.2 Don't get back what I put
  33.                                     in the scrapbook. Changed ODMemContainer so
  34.                                     that it has a constructor that makes a new
  35.                                     container given a container handle.
  36.         <27>    10/13/95    EL        1287340: Use standard ISO prefix
  37.         <26>     10/4/95    jpa        Added missing ODVolatiles [1285799]
  38.         <25>     10/4/95    VL        1287585: Check to see whether we are
  39.                                     dragging a folder before getting the file
  40.                                     info.
  41.         <24>     9/13/95    VL        1283523: Stop copying names for stationery
  42.                                     files.
  43.         <23>      9/8/95    VL        1274572: Preserved the curResFile in
  44.                                     GetIconFamilyFromFile.
  45.         <22>      9/8/95    TÇ        1281096 FB2:Many constants in ODTypesB
  46.                                     without kOD prefix!
  47.         <21>      9/6/95    VL        1274572: Added GetFinderInfo and
  48.                                     GetIconFamilyFromFile.
  49.         <20>     8/12/95    TÇ        1276812 Need to use TempObjs and TempRefs
  50.                                     for exception safety and to avoid TRY
  51.                                     blocks, 1276807 Opt./Bug: use StdTypIO
  52.                                     routines for portable streaming & smaller
  53.                                     footprint
  54.         <19>     7/26/95    VL        1270320: ClearAllPromises when deleting
  55.                                     memory container.
  56.         <18>     5/26/95    VL        1251403: Multithreading naming support.
  57.         <17>     5/25/95    jpa        Fixed usage of ODDebug. [1253321]
  58.         <16>     4/25/95    VL        1240737: Make sure that ID for file
  59.                                     container is set to the right _length.
  60.         <15>     4/15/95    VL        1240014: turned off debug statements.
  61.         <14>     4/14/95    VL        Temporarily turned on debug printf.
  62.         <13>     3/10/95    VL        1227218: Get rid of system heap.
  63.         <12>     2/27/95    VL        1198037: Removed debugstr from code.
  64.         <11>     2/10/95    VL        1205627: Used kODBentoUpdateContainer.
  65.         <10>     1/26/95    VL        #???: Use updated Storage Unit Ref API.
  66.          <9>     1/19/95    CC        1212419 Pass kODBentoMemoryContainer to
  67.                                     CreateMemoryContainer & GetMemoryContainer.
  68.          <8>    12/20/94    VL        1195012: Make Storage calls be
  69.                                     marshallable.
  70.          <7>    12/13/94    VL        1203627,1200603,1203451,1198037,1194537,119
  71.                                     4755,1186815: Bug fixes.
  72.          <6>     9/23/94    VL        1184272: ContainerID is now a sequence of
  73.                                     octets.
  74.          <5>     8/26/94    VL        1183174: Use updated cloning APIs
  75.                                     (specifically GetStorageUnitRef takes ID
  76.                                     now).
  77.          <4>     8/15/94    TÇ        #1180922 Removed most obsolete types from
  78.                                     StdTypes.idl
  79.          <3>      8/3/94    VL        1153123: Storage to ODStor.
  80.          <2>     7/26/94    VL        Got rid of dependency on Bento.
  81.          <1>     7/21/94    VL        first checked in
  82.  
  83.     To Do:
  84.     In Progress:
  85.         
  86. */
  87.  
  88. #ifndef _DRAGPRIV_
  89. #include <DragPriv.h>
  90. #endif
  91.  
  92. #ifndef SOM_ODStorageSystem_xh
  93. #include <ODStor.xh>
  94. #endif
  95.  
  96. #ifndef SOM_ODContainer_xh
  97. #include <ODCtr.xh>
  98. #endif
  99.  
  100. #ifndef SOM_ODDocument_xh
  101. #include <Document.xh>
  102. #endif
  103.  
  104. #ifndef SOM_ODDraft_xh
  105. #include <ODDraft.xh>
  106. #endif
  107.  
  108. #ifndef SOM_ODStorageUnit_xh
  109. #include <StorageU.xh>
  110. #endif
  111.  
  112. #ifndef _ODMEMORY_
  113. #include "ODMemory.h"
  114. #endif
  115.  
  116. #ifndef _STDTYPIO_
  117. #include "StdTypIO.h"
  118. #endif
  119.  
  120. #ifndef _TEMPOBJ_
  121. #include "TempObj.h"
  122. #endif
  123.  
  124. #ifndef SOM_Module_OpenDoc_StdProps_defined
  125. #include <StdProps.xh>
  126. #endif
  127.  
  128. #ifndef SOM_Module_OpenDoc_StdTypes_defined
  129. #include <StdTypes.xh>
  130. #endif
  131.  
  132. #ifndef SOM_ODTranslation_xh
  133. #include <Translt.xh>
  134. #endif
  135.  
  136. #ifndef _STORUTIL_
  137. #include <StorUtil.h>
  138. #endif
  139.  
  140. #ifndef _BARRAY_
  141. #include <BArray.h>
  142. #endif
  143.  
  144. #ifndef _ISOSTR_
  145. #include <ISOStr.h>
  146. #endif
  147.  
  148. #ifndef _INFOUTIL_
  149. #include <InfoUtil.h>
  150. #endif
  151.  
  152. #ifndef _ICONS_
  153. #include <Icons.h>
  154. #endif
  155.  
  156. #ifndef _PLFMFILE_
  157. #include <PlfmFile.h>
  158. #endif
  159.  
  160. #ifndef _USERSRCM_
  161. #include <UseRsrcM.h>
  162. #endif
  163.  
  164. #ifndef __FINDER__
  165. #include <Finder.h>
  166. #endif
  167.  
  168. #ifndef _CONSTDEF_
  169. #include "ConstDef.h"
  170. #endif
  171.  
  172. //#ifndef _BENTOSUPPRESS_
  173. //#include <BentoSuppress.h>
  174. //#endif
  175.  
  176. #if ODDebug
  177. #ifndef __STRINGS__
  178. #include <Strings.h>
  179. #endif
  180. #endif
  181.  
  182. #if ODDebug
  183. // #define ODDebug_DragPriv    1
  184. #endif
  185.  
  186. const ODContainerType kODBentoUpdateContainer = "+//ISO 9070/ANSI::113722::US::CI LABS::OpenDoc:Bento Container Suite:ContainerType:Update";
  187.  
  188. //==============================================================================
  189. // Function Prototype
  190. //==============================================================================
  191.  
  192. ODContainerType    GetContainerSuiteType(FSSpec* fsSpec);
  193.  
  194. //==============================================================================
  195. // ODDragItem
  196. //==============================================================================
  197. //------------------------------------------------------------------------------
  198. // ODDragItem::ODDragItem
  199. //------------------------------------------------------------------------------
  200. ODDragItem::ODDragItem(ODStorageSystem *storage, ODBoolean IsForeignDataSU,
  201.                                 ODPlatformDragReference currentDrag,
  202.                                 ItemReference theDragItemRefNumber,
  203.                                 HFSFlavor*    hfsFlavor)
  204. {
  205.     fStorageSystem                 = storage;
  206.     fCurrentDragItemRefNumber    = theDragItemRefNumber;
  207.     fCurrentDrag                 = currentDrag;
  208.     fHFSFlavorPtr                 = hfsFlavor;
  209.  
  210.     fContainer = kODNULL;
  211.     fDocument = kODNULL;
  212.     fDraft = kODNULL;
  213.     fSU = kODNULL;
  214. }
  215.  
  216. //------------------------------------------------------------------------------
  217. // ODDragItem::Open
  218. //------------------------------------------------------------------------------
  219. void ODDragItem::Open(Environment* ev)
  220. {
  221.     WARN("ODDragItem::Open should not be called.");
  222. }
  223.  
  224.  
  225. //------------------------------------------------------------------------------
  226. // ODDragItem::Close
  227. //------------------------------------------------------------------------------
  228. void ODDragItem::Close(Environment* ev)
  229. {
  230.     WARN("ODDragItem::Open should not be called.");
  231. }
  232.  
  233. //------------------------------------------------------------------------------
  234. // ODDragItem::AddFinderInfoToSU
  235. //------------------------------------------------------------------------------
  236. void ODDragItem::AddFinderInfoToSU( Environment* ev )
  237. {
  238.     // Integrating code from EnterHandler to now generate Finder Info here.
  239.  
  240.     // If the drag item was an HFS flavor, then write out the Finder info here
  241.     // so that a part could mimic the Finder and have all  of the Finder
  242.     // info available to it. Otherwise, parts have not have enough info
  243.     // to deal with Finder files.
  244.  
  245.     TRY
  246.         if ( fHFSFlavorPtr != kODNULL )
  247.         {
  248.             TempPlatformFile finderFile = new PlatformFile;
  249. //            finderFile = new PlatformFile();
  250.             finderFile->Specify(&(fHFSFlavorPtr->fileSpec));
  251.         
  252.             GetFinderInfo(ev, fSU, finderFile);
  253.             GetIconFamilyFromFile(ev, fSU, finderFile);
  254.         }
  255.     CATCH_ALL
  256.         // If the drag item is not a finder file, like from the Scrapbook,
  257.         // then we don't have anything to add. Therefor, don't reraise if there
  258.         // are exceptions.
  259.     ENDTRY
  260. }
  261.  
  262. //------------------------------------------------------------------------------
  263. // ODDragItem::AddMacOSTypeInfoToSU
  264. //------------------------------------------------------------------------------
  265. void ODDragItem::AddMacOSTypeInfoToSU( Environment* ev )
  266. {
  267.     // Now add old-style MacOS kinds to the SU, if kinds were dragged from a non-OpenDoc
  268.     // process. Otherwise, don't need to do anything.
  269.     
  270.     if( fCurrentDrag != 0 )
  271.     {
  272.         // Go through all of the flavors in the drag item, and add an ISO kind to the
  273.         // storage unit. These will constitute the multiple kinds that a drag
  274.         // might have. For example, if an app wrote out TEXT and STYL kinds, we want
  275.         // those both to be available to a part in the data transfer SU.
  276.         ODUShort            numDragFlavors = 0;
  277.         ODTranslation*        translation         = fStorageSystem->GetSession(ev)->GetTranslation(ev);
  278.         CountDragItemFlavors(fCurrentDrag, fCurrentDragItemRefNumber, &numDragFlavors);
  279.         
  280.         for ( ODUShort dragFlavorIndex = 1; dragFlavorIndex <= numDragFlavors; dragFlavorIndex++)
  281.         {
  282.             OSType        theType;
  283.             OSErr        err = GetFlavorType(fCurrentDrag, fCurrentDragItemRefNumber, dragFlavorIndex, &theType);
  284.             TempODValueType isoType = kODNULL;
  285.             isoType = translation->GetISOTypeFromPlatformType(ev, theType, kODPlatformDataType);
  286.             fSU->Focus(ev, kODPropContents, kODPosUndefined, kODNULL,
  287.                       0, kODPosUndefined);
  288.             StorageUnitSetPromiseValue(fSU, ev, isoType, 0,
  289.                                         sizeof(ItemReference), &fCurrentDragItemRefNumber, kODNULL);
  290.             // ODDisposePtr(isoType);   // No longer needed because it is now temp.
  291.             // If theType is 'styl', add a promise for 'stxt'
  292.             if ( theType == kODScrapTypestyl )
  293.             {
  294.                 if ( DragItemHasFlavor(fCurrentDrag, fCurrentDragItemRefNumber, kODScrapTypeTEXT) &&
  295.                      !DragItemHasFlavor(fCurrentDrag, fCurrentDragItemRefNumber, kODScrapTypestxt) )
  296.                     StorageUnitSetPromiseValue(fSU, ev, kODApplestxt, 0,
  297.                                                sizeof(ItemReference), &fCurrentDragItemRefNumber, kODNULL);
  298.             }
  299.             else if (theType == flavorTypeHFS)
  300.             {
  301.                 TempODValueType isoType = translation->GetISOTypeFromPlatformType(ev, 
  302.                                             fHFSFlavorPtr->fileType, kODPlatformFileType);
  303.                 fSU->AddValue(ev, isoType);
  304.                 // ODDisposePtr(isoType);   // No longer needed because it is now temp.
  305.             }
  306.         }
  307.     }
  308. }
  309.  
  310. //==============================================================================
  311. // ODMemDragItem
  312. //==============================================================================
  313. //------------------------------------------------------------------------------
  314. // ODMemDragItem::~ODMemDragItem
  315. //------------------------------------------------------------------------------
  316.  
  317. ODMemDragItem::~ODMemDragItem()
  318. {
  319.     Environment* ev = somGetGlobalEnvironment();
  320.  
  321.     if (fSU != kODNULL)
  322.     {
  323.         fSU->ClearAllPromises(ev);
  324.         ODSafeReleaseObject( fSU );
  325.     }
  326.     ODSafeReleaseObject( fDraft );
  327.     ODSafeReleaseObject( fDocument );
  328.     ODSafeReleaseObject( fContainer);
  329.     if( fContainerHandle != kODNULL)
  330.         ODDisposeHandle(fContainerHandle);
  331. }
  332.  
  333. //------------------------------------------------------------------------------
  334. // ODMemDragItem::Initialize
  335. //------------------------------------------------------------------------------
  336. void ODMemDragItem::Initialize(Environment* ev)
  337. {
  338.     ODDragItem::Initialize(ev);
  339.     
  340.     // Need to do this acquire so we will have the same number of releases
  341.     // whether the DragItem is used or not.
  342.     if( fDraft != kODNULL )
  343.         fDraft->Acquire(ev);
  344. }
  345.  
  346. //------------------------------------------------------------------------------
  347. // ODMemDragItem::Open
  348. //------------------------------------------------------------------------------
  349. void ODMemDragItem::Open(Environment* ev)
  350. {
  351.     if( fContainerHandle )
  352.     {
  353.         TRY
  354.             fContainer = GetMemoryContainer(ev, fStorageSystem->GetSession(ev), 
  355.                                             fContainerHandle, kODBentoMemoryContainer);
  356.             fDocument = fContainer->AcquireDocument(ev, kODDefaultDocument);
  357.             fDraft = fDocument->AcquireBaseDraft(ev, kODDPExclusiveWrite);
  358.             TempODStorageUnit    draftProperties = fDraft->AcquireDraftProperties(ev);
  359.             fSU = fDraft->AcquireStorageUnit(ev, ODGetStrongSURefProp(ev, draftProperties,
  360.                                          kODPropRootPartSU, kODStrongStorageUnitRef));
  361.         CATCH_ALL
  362.             if (fSU != kODNULL)
  363.             {
  364.                 ODSafeReleaseObject( fSU );
  365.                 fSU = kODNULL;
  366.             }
  367.             if (fDraft != kODNULL)
  368.             {
  369.                 ODSafeReleaseObject( fDraft );
  370.                 fDraft = kODNULL;
  371.             }
  372.             if (fDocument != kODNULL)
  373.             {
  374.                 ODSafeReleaseObject( fDocument );
  375.                 fDocument = kODNULL;
  376.             }
  377.             if (fContainer != kODNULL)
  378.             {
  379.                 ODSafeReleaseObject( fContainer );
  380.                 fContainer = kODNULL;
  381.             }
  382.             if( fContainerHandle != kODNULL)
  383.                 ODDisposeHandle(fContainerHandle);
  384.             RERAISE;
  385.         ENDTRY
  386.     }
  387.     else if( fDraft )
  388.     {
  389.         fSU = fDraft->CreateStorageUnit(ev);
  390.     }
  391. }
  392.  
  393. //------------------------------------------------------------------------------
  394. // ODMemDragItem::Close
  395. //------------------------------------------------------------------------------
  396. void ODMemDragItem::Close(Environment* ev)
  397. {
  398.     ODSafeReleaseObject( fSU );
  399.     if (fDraft != kODNULL) {
  400.         fDraft->Externalize(ev);
  401.         ODSafeReleaseObject( fDraft );
  402.     }
  403.     ODSafeReleaseObject( fDocument );
  404.     ODSafeReleaseObject( fContainer );
  405. }
  406.  
  407.  
  408. //------------------------------------------------------------------------------
  409. // ODMemDragItem::GetStorageUnit
  410. //------------------------------------------------------------------------------
  411. ODStorageUnit*    ODMemDragItem::GetStorageUnit(Environment* ev)
  412. {
  413.     if( fSU == kODNULL )
  414.     {
  415.         TRY
  416.             Open( ev );
  417.                     
  418.             AddFinderInfoToSU(ev);
  419.             AddMacOSTypeInfoToSU(ev);        
  420.         CATCH_ALL
  421.     #ifdef ODDebug_DragPriv
  422.             ODError err = ErrorCode();
  423.             WARN("Error in ODFileDragItem::Initialize");
  424.             char    errString[100];
  425.             numtostring(err, errString);
  426.             WARN(errString);
  427.     #endif
  428.             if (fSU != kODNULL)
  429.             {
  430.                 ODSafeReleaseObject( fSU );
  431.                 fSU = kODNULL;
  432.             }
  433.             if (fDraft != kODNULL)
  434.             {
  435.                 ODSafeReleaseObject( fDraft );
  436.                 fDraft = kODNULL;
  437.             }
  438.             if (fDocument != kODNULL)
  439.             {
  440.                 ODSafeReleaseObject( fDocument );
  441.                 fDocument = kODNULL;
  442.             }
  443.             if (fContainer != kODNULL)
  444.             {
  445.                 ODSafeReleaseObject( fContainer );
  446.                 fContainer = kODNULL;
  447.             }
  448.             RERAISE;
  449.         ENDTRY
  450.     }
  451.     return fSU;
  452. }
  453.  
  454. //==============================================================================
  455. // ODFileDragItem
  456. //==============================================================================
  457.  
  458.  
  459. //------------------------------------------------------------------------------
  460. // ODFileDragItem::~ODFileDragItem
  461. //------------------------------------------------------------------------------
  462. ODFileDragItem::~ODFileDragItem()
  463. {
  464. #if ODDebug_DragPriv
  465.     somPrintf("~ODFileDragItem: %x %x %x %x\n", fSU, fDraft, fDocument, fContainer);
  466. #endif
  467.  
  468.     Environment* ev = somGetGlobalEnvironment();
  469.     
  470.     ODSafeReleaseObject( fSU );
  471.     ODSafeReleaseObject( fDraft );
  472.     ODSafeReleaseObject( fDocument );
  473.     ODSafeReleaseObject( fContainer );
  474.     if (fContainerID)
  475.         DisposeByteArray(fContainerID);
  476. }
  477.  
  478. //------------------------------------------------------------------------------
  479. // ODFileDragItem::Initialize
  480. //------------------------------------------------------------------------------
  481. void ODFileDragItem::Initialize(Environment* ev, ODContainerID* containerID )
  482. {    
  483.     ODDragItem::Initialize(ev);
  484.     fContainerID = CopyByteArray(containerID);
  485. }
  486.  
  487. //------------------------------------------------------------------------------
  488. // ODFileDragItem::GetStorageUnit
  489. //------------------------------------------------------------------------------
  490. ODStorageUnit* ODFileDragItem::GetStorageUnit(Environment* ev)
  491. {
  492.     if (fSU == kODNULL)
  493.     {            
  494.     ODStorageUnitID    suid;
  495.     ODContainerType containerType = kODNULL;    ODVolatile(containerType);
  496.         
  497.     TRY
  498.         containerType = GetContainerSuiteType((FSSpec*) fContainerID->_buffer);
  499.         fContainerID->_length = sizeof(short) + sizeof(long) + ((FSSpec*) fContainerID->_buffer)->name[0] + 1;
  500.         fContainer = fStorageSystem->CreateContainer(ev, containerType, fContainerID);
  501.         fDocument = fContainer->AcquireDocument(ev, kODDefaultDocument);        
  502.         fDraft = fDocument->AcquireBaseDraft(ev, kODDPExclusiveWrite);
  503.         TempODStorageUnit    draftProperties = fDraft->AcquireDraftProperties(ev);
  504.         suid = ODGetStrongSURefProp(ev, draftProperties, kODPropRootPartSU, kODStrongStorageUnitRef);
  505.         fSU = fDraft->AcquireStorageUnit(ev, suid);
  506.  
  507.         AddFinderInfoToSU(ev);
  508.         AddMacOSTypeInfoToSU(ev);
  509.  
  510.         ODDisposePtr(containerType);
  511.             
  512.     #if ODDebug_DragPriv
  513.         somPrintf("ODFileDragItem::Initialize %x %x %x %x\n", fSU, fDraft, fDocument, fContainer);
  514.     #endif
  515.     
  516.     CATCH_ALL
  517.     #ifdef ODDebug_DragPriv
  518.         ODError err = ErrorCode();
  519.         WARN("Error in ODFileDragItem::Initialize");
  520.         char    errString[100];
  521.         numtostring(err, errString);
  522.         WARN(errString);
  523.     #endif
  524.         if (fSU != kODNULL)
  525.         {
  526.             ODSafeReleaseObject( fSU );
  527.             fSU = kODNULL;
  528.         }
  529.         if (fDraft != kODNULL)
  530.         {
  531.             ODSafeReleaseObject( fDraft );
  532.             fDraft = kODNULL;
  533.         }
  534.         if (fDocument != kODNULL)
  535.         {
  536.             ODSafeReleaseObject( fDocument );
  537.             fDocument = kODNULL;
  538.         }
  539.         if (fContainer != kODNULL)
  540.         {
  541.             ODSafeReleaseObject( fContainer );
  542.             fContainer = kODNULL;
  543.         }
  544.         if( containerType )
  545.             ODDisposePtr(containerType);
  546.         RERAISE;
  547.     ENDTRY
  548.     }
  549.     return fSU;
  550. }
  551.  
  552. //==============================================================================
  553. // ODDragLink
  554. //==============================================================================
  555. //------------------------------------------------------------------------------
  556. // ODDragLink::ODDragLink
  557. //------------------------------------------------------------------------------
  558. ODDragLink::ODDragLink(ODDragItem *theItem, ODBoolean cleanup)
  559. {
  560.     fItem = theItem;
  561.     fCleanup = cleanup;
  562. }
  563.  
  564. //------------------------------------------------------------------------------
  565. // ODDragLink::~ODDragLink
  566. //------------------------------------------------------------------------------
  567. ODDragLink::~ODDragLink()
  568. {
  569.     if (fCleanup)
  570.         delete fItem;
  571. }
  572.  
  573. //------------------------------------------------------------------------------
  574. // GetContainerSuiteType
  575. //------------------------------------------------------------------------------
  576.  
  577. ODContainerType    GetContainerSuiteType(FSSpec* fsSpec)
  578. {
  579. #if USE_GETCONTAINER_SUITE_TYPE
  580.     PlatformFile    file;
  581.     file.Specify(fsSpec);
  582.     
  583.     ODContainerType containerType = file.AcquireContainerType();
  584.     if (ODISOStrEqual(containerType, kODBentoFileContainer) || 
  585.         ODISOStrEqual(containerType, "")) {
  586.         containerType = kODBentoUpdateContainer;
  587.     }
  588. #else
  589.     ODULong len = strlen(kODBentoUpdateContainer);
  590.     ODContainerType containerType = (ODContainerType) ODNewPtr(len + 1);
  591.     strcpy(containerType, kODBentoUpdateContainer);
  592.     return containerType;
  593. #endif
  594. }
  595.  
  596. //------------------------------------------------------------------------------
  597. // GetFinderInfo
  598. //------------------------------------------------------------------------------
  599. void GetFinderInfo(Environment* ev, ODStorageUnit* su, PlatformFile* file)
  600. {
  601.     if (!file->IsDirectory())
  602.     {
  603.         ODTime creationDate = file->GetFileCreationDate();
  604.         ODSetCreationDate(ev, su, creationDate);
  605.         ODTime modDate = file->GetFileModDate();
  606.         ODSetModificationDate(ev, su, modDate);
  607.     
  608.         if (!file->IsStationery())
  609.         {    
  610.             ODName* name = file->GetName();
  611.             ODSetPONameUsingSU(ev, su, name);
  612.             DisposeIText(name);
  613.         }
  614.     
  615.         // Stationery bit is purposedly left out.
  616.     }
  617. }
  618.  
  619. //------------------------------------------------------------------------------
  620. // GetIconFamilyFromFile
  621. //------------------------------------------------------------------------------
  622. void GetIconFamilyFromFile(Environment* ev, ODStorageUnit* su, PlatformFile* file)
  623. {
  624.     if (!file->IsDirectory())
  625.     {
  626.         Handle iconFamily;
  627.         
  628.         short refNum = 0;
  629.         ODBoolean hasCustomIcon;
  630.         OSErr err = noErr;
  631.         ODVolatile(err);
  632.         TRY
  633.             hasCustomIcon = file->HasCustomIcon();
  634.             if (hasCustomIcon)
  635.             {
  636.                 file->SetPermission(fsRdPerm);
  637.                 refNum = CurResFile();
  638.                 err = ResError();
  639.                 if( err == noErr )
  640.                     file->OpenResFile();
  641.             }
  642.         CATCH_ALL
  643.             file->CloseResFile();
  644.             UseResFile(refNum);
  645.         ENDTRY
  646.         
  647.         if (hasCustomIcon && (err == noErr))
  648.         {        
  649.             err = GetIconSuite(&iconFamily, kCustomIconResource, svAllAvailableData);
  650.             if (err == noErr)
  651.             {
  652.                 ODSetIconFamilyProp(ev, su, kODPropCustomIcon, kODIconFamily, iconFamily, kODFalse);
  653.                 DisposeIconSuite(iconFamily, true);
  654.             }
  655. #ifdef ODDEBUG
  656.             else
  657.                 WARN("Problem getting icon family: %d ", err);
  658. #endif
  659.             file->CloseResFile();
  660.         }
  661.     }
  662. }
  663.  
  664.